#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
RAG系统快速测试
"""

import sys
import os

# 添加当前目录到Python路径
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))

def test_rag():
    print("=" * 50)
    print("RAG系统快速测试")
    print("=" * 50)
    
    try:
        # 测试简化版RAG系统
        print("1. 测试简化版RAG系统...")
        from simple_rag_system import SimpleRAGSystem
        rag = SimpleRAGSystem()
        print("   ✓ 简化版RAG系统初始化成功")
        
        # 测试问答
        print("2. 测试问答功能...")
        result = rag.get_answer("乳腺癌有哪些症状？")
        print(f"   ✓ 问答成功，置信度: {result['confidence']:.2f}")
        print(f"   ✓ 答案: {result['answer'][:100]}...")
        
        # 测试搜索
        print("3. 测试搜索功能...")
        results = rag.search("症状", top_k=2)
        print(f"   ✓ 搜索成功，找到{len(results)}条结果")
        
        print("=" * 50)
        print("✓ 所有测试通过！RAG系统工作正常")
        print("=" * 50)
        return True
        
    except Exception as e:
        print(f"✗ 测试失败: {e}")
        import traceback
        traceback.print_exc()
        return False

if __name__ == "__main__":
    success = test_rag()
    if success:
        print("\n🎉 RAG系统测试成功！")
    else:
        print("\n❌ RAG系统测试失败！")
    
    input("\n按回车键退出...")
